//
//  CBTCountryCodeCell.m
//  CBT
//
//  Created by Mr.Zhang on 2018/11/27.
//  Copyright © 2018 Mr.Zhang. All rights reserved.
//

#import "CBTCountryCodeCell.h"

@interface CBTCountryCodeCell()

@property (nonatomic, strong) UILabel *countryLabel;
@property (nonatomic, strong) UILabel *codeLabel;

@end

@implementation CBTCountryCodeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        [self initSubViews];
    }
    return self;
}

-(void)setDic:(NSDictionary *)dic
{
    self.countryLabel.text = dic[@"country"];
    self.codeLabel.text = [NSString stringWithFormat:@"+%@",dic[@"code"]];
}

- (void)initSubViews
{
    _countryLabel = [[UILabel alloc]init];
    _countryLabel.font = [UIFont systemFontOfSize:15];
    _countryLabel.textColor = UIColorFromRGB(0x666666);
    [self.contentView addSubview:_countryLabel];
    
    _codeLabel = [[UILabel alloc]init];
    _codeLabel.font = [UIFont systemFontOfSize:15];
    _codeLabel.textColor = UIColorFromRGB(0x666666);
    [self.contentView addSubview:_codeLabel];
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    [_countryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.bottom.mas_equalTo(0);
    }];
    
    [_codeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.top.bottom.mas_equalTo(0);
    }];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
